
package com.tools.cleanmaster.ui.view.trash;

import android.graphics.drawable.Drawable;

import com.tools.cleanmaster.R;
import com.tools.cleanmaster.appinfo.AppManager;
import com.tools.cleanmaster.model.TrashType;
import com.tools.cleanmaster.model.item.TrashItem;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@SuppressWarnings("static-access")
public class TrashMemGroup extends TrashGroup {

    private final AppManager mAppMgr;

    public TrashMemGroup() {
        super(null);
        mAppMgr = AppManager.getInstance(mContext);
    }

    @Override
    public Drawable getIcon() {
        return mContext.getResources().getDrawable(R.drawable.icon_trash_clean_memory);
    }

    @Override
    public String getTitle() {
        return mContext.getResources().getString(R.string.memory_trash_item);
    }

    @Override
    public void fillTrashes(Map<TrashType, List<TrashItem>> trashes) {
        List<TrashItem> list = trashes.get(TrashType.APP_MEM);
        if (list != null && !list.isEmpty()) {
            for (TrashItem trashItem : list) {
                addChildItem(new AppTrash(trashItem, mAppMgr.getAppInfo(trashItem.pkgName), this));
            }
            // 设置check状态
            setCheckStateByChild();
            Collections.sort(mChildItems);
        }
    }

}
